package com.itheima.HomeWork_day10;
/*
可变参数
 */
public class VarPara06 {
    public static void main(String[] args) {

        getSum(1,2,3,5,9);

        getSum2(50,25,60);

    }

    private static void getSum(int ... arr) {
            int sum=0;
        for (int i = 0; i < arr.length; i++) {
            sum+=arr[i];
        }
        System.out.println(sum);
    }

    //可变参数添加多个参数时,可变参数只能放在后面
    private static void getSum2(int num,int ... arr) {
        int sum=0;
        for (int i = 0; i < arr.length; i++) {
            sum+=arr[i];
        }
        System.out.println(num);
        System.out.println(sum);
    }
}
